package com.sgcc.operate.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sgcc.common.log.annotation.Log;
import com.sgcc.common.log.enums.BusinessType;
import com.sgcc.common.security.annotation.PreAuthorize;
import com.sgcc.operate.domain.OIndiContent;
import com.sgcc.operate.service.IOIndiContentService;
import com.sgcc.common.core.web.controller.BaseController;
import com.sgcc.common.core.web.domain.AjaxResult;
import com.sgcc.common.core.utils.poi.ExcelUtil;
import com.sgcc.common.core.web.page.TableDataInfo;

/**
 * 方案指标内容Controller
 * 
 * @author sgcc
 * @date 2021-03-24
 */
@RestController
@RequestMapping("/indicontent")
public class OIndiContentController extends BaseController
{
    @Autowired
    private IOIndiContentService oIndiContentService;

    /**
     * 查询方案指标内容列表
     */
    //@PreAuthorize(hasPermi = "operate:indicontent:list")
    @GetMapping("/list")
    public TableDataInfo list(OIndiContent oIndiContent)
    {
        startPage();
        List<OIndiContent> list = oIndiContentService.selectOIndiContentList(oIndiContent);
        return getDataTable(list);
    }

    /**
     * 导出方案指标内容列表
     */
    //@PreAuthorize(hasPermi = "operate:indicontent:export")
    @Log(title = "方案指标内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OIndiContent oIndiContent) throws IOException
    {
        List<OIndiContent> list = oIndiContentService.selectOIndiContentList(oIndiContent);
        ExcelUtil<OIndiContent> util = new ExcelUtil<OIndiContent>(OIndiContent.class);
        util.exportExcel(response, list, "indicontent");
    }

    /**
     * 获取方案指标内容详细信息
     */
    //@PreAuthorize(hasPermi = "operate:indicontent:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(oIndiContentService.selectOIndiContentById(id));
    }

    /**
     * 新增方案指标内容
     */
    //@PreAuthorize(hasPermi = "operate:indicontent:add")
    @Log(title = "方案指标内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OIndiContent oIndiContent)
    {
        return toAjax(oIndiContentService.insertOIndiContent(oIndiContent));
    }

    /**
     * 修改方案指标内容
     */
    //@PreAuthorize(hasPermi = "operate:indicontent:edit")
    @Log(title = "方案指标内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OIndiContent oIndiContent)
    {
        return toAjax(oIndiContentService.updateOIndiContent(oIndiContent));
    }

    /**
     * 删除方案指标内容
     */
    //@PreAuthorize(hasPermi = "operate:indicontent:remove")
    @Log(title = "方案指标内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(oIndiContentService.deleteOIndiContentByIds(ids));
    }
}
